set more off
graph drop _all

use Data/event_study_sample_quartsince2006.dta, clear 

	
 
	gen nexis_buildings  = ROOFME/PROOFME
		
		
	gen roofratio = ROOFME/ROOFTI
	gen roofratiobuildings = roofratio*nexis_buildings
		
	gen roofrelativeIV = (roofratio*nexis_buildings/[moduleprice])/1000

	
	
	* keep estimation sample only 
	xi: xtivreg green_p (cuminst = roofrelativeIV)  i.quarter , fe
	
	
	keep if e(sample) ==1
	by postcode, sort: gen N =_N 
	drop if N==1
	
	keep postcode quarter
	
	gen mysample =1
	
	merge 1:1 postcode quarter using Data/event_study_sample_quartsince2006.dta
	
	drop _merge
	replace mysample =0 if mysample ==.
	
	keep if mysample==1
 
 
 

	label variable green_plan "Share Green" 
	label variable cumins "Solar Panels (000s)"
	label variable mean_weighted "Average Electricity Tariff"
	label variable TotalHouse_interp "Dwellings (000s)"
	label variable PSeparate_interp "Proportion Separate Dwellings (000s)"
	label variable Separate_interp "Separate Dwellings (000s)"
	label variable median_income_interp "Median Income (000/week)"
	label variable median_mortgage_interp "Median Mortgage Payment (000/month)"
	label variable median_rent_interp "Median Rental Payment (000/week)" 
	label variable PBachelor_interp "Proportion Bachelor's Degree"
	label variable PRented_interp "Proportion Rental Properties"
	label variable median_rooms_interp "Median House Size"
	label variable PFullTime_interp "Proportion Employed Full Time"
	label variable median_age_interp "Median Age"
	label variable mean_weighted "Electricity Tariff (per kWh)"
	label variable PROOFME "Proportion Roof Metal"	
	label variable PROOFTI "Proportion Roof Tile"
	

 
 save Data/Estimation_sample.dta, replace
 
 
 use Data/Estimation_sample.dta, clear
 
 keep postcode 
 
 duplicates drop
 
 save Data/Estimation_postcodes.dta, replace
